﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GtsServer.Service.Model;
using GtsServer.DAL;
using System.Data;

namespace GtsServer.Service.Controller
{
    public class RechargeRecordController
    {
        public RechargeRecordResponse RechargeRecord(RechargeRecordRequest request)
        {
            RechargeRecordResponse response = new RechargeRecordResponse()
            {
                record_list = new List<RechargeRecordManage>()
            };

            string userAccount = BaseController.Account(request.info);

            if (string.IsNullOrEmpty(userAccount))
                return response;

            OrderDAL dal = new OrderDAL();
            DataSet ds = dal.GetRechargeRecord(userAccount);

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow item in ds.Tables[0].Rows)
                {
                    RechargeRecordManage model = new RechargeRecordManage() {
                        name = item["Name"].ToString(),
                        price = Convert.ToInt32(item["Price"]),
                        time = item["CreateTime"].ToString(),
                        pay_medth = item["payMedth"].ToString(),
                    };
                    response.record_list.Add(model);
                }
            }
            return response;
        }
    }
}
